﻿define([
    "epi",
    "dojo",
    "dojo/_base/lang",
    "dojo/_base/connect",
    "dojo/_base/array",

    "ow-epi-listProperty/widgets/ListItemPropertyWidget",

    "dojo/text!./ImageListItemPropertyWidget.html",
    "xstyle/css!./ImageListItemPropertyWidget.css"
],

function (
    epi,
    dojo,
    lang,
    connect,
    array,

    _ListItemPropertyWidget,

    template
) {

    return dojo.declare("ow-epi-listProperty.widgets.ListItemPropertyWidget", [_ListItemPropertyWidget], {

        templateString: template,

        baseClass: 'list-property-item-image',

        postMixInProperties: function () {
            this.inherited(arguments);
        },

        postCreate: function () {
            this.inherited(arguments);
        },

        _setListItemAttr: function (value) {
            this._set('listItem', value);

            this.nodeImage.src = this.listItem[this.imageUrlPropertyName] + "?t=ScaleDownToFit|100x100";
            if (this.imageTitlePropertyName) {
                this.nodeImage.title = this.listItem[this.imageTitlePropertyName];
            }

            dojo.attr(this.domNode, { dndData: this._getDndData() });
        }
    });
});